#include <iostream>
#include <pthread.h>
#include <mutex>
using namespace std;
class myMtuex
{
public:
    myMtuex(pthread_mutex_t &mtx) : _mtx(mtx)
    {
        pthread_mutex_lock(&_mtx);
        cout << "加锁成功" << endl;
    }
    ~myMtuex()
    {
        pthread_mutex_unlock(&_mtx);
        cout << "解锁成功" << endl;
    }

private:
    pthread_mutex_t &_mtx;
};